<%@page import="systems.AdsSystem"%>
<%@page import="entities.MetaSeo"%>
<%@page import="helpers.StringHelper"%>
<%@page import="java.util.TreeMap"%>
<%@page import="java.util.Map"%>
<%@page import="helpers.UrlHelper"%>
<%@page import="entities.KeywordRanking"%>
<% 
String name  = (String) request.getAttribute("name");
KeywordRanking keyword = (KeywordRanking) request.getAttribute("keyword");
String error = (String) request.getAttribute("error");
MetaSeo metaseo = (MetaSeo) request.getAttribute("metaseo");

//Set content for Seo
Map<String, String> replates = new TreeMap<String, String>();
replates.put("__SERVER_NAME__", UrlHelper.getDomainServer(request));
replates.put("__SERVER_URL__", UrlHelper.getServerUrl(request));

String title = StringHelper.replateContent(metaseo.getTitle(), replates);
String description = StringHelper.replateContent(metaseo.getDescription(), replates);
String keywords = StringHelper.replateContent(metaseo.getKeywords(), replates);
String url = StringHelper.replateContent(metaseo.getOgurl(), replates);

if (keyword != null) {
	replates.put("__DOMAIN_NAME__", keyword.getDomain());
	
	title = StringHelper.replateContent(metaseo.getTitleInfo(), replates);
	description = StringHelper.replateContent(metaseo.getDescriptionInfo(), replates);
	keywords = StringHelper.replateContent(metaseo.getKeywordsInfo(), replates);
	url = StringHelper.replateContent(metaseo.getOgurlInfo(), replates);
}
%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="/templates/default/layouts/header.jsp" />

		<div class="row-fluid clearfix">
			<!-- Main Content -->
			<div class="span9 main-content domain-info">
				<section>
					<div class="block">
						<div class="block-content no-bg">
							<h3>Check Keyword Ranking</h3>
							<div class="adv">
								<%=AdsSystem.getAds468x15() %>
								<br />
							</div>
							<section id="search-bar">
								<div class="item-stream unstyled search-input-stream">
									<div class="stream-item stream-header search-input-item">
										<form action="/kranking" class="form-inline search-form">
											<input type="text" role="textbox" class="xlarge ui-autocomplete-input" id="artist_search" name="q" placeholder="ex: google.com" value="">
					          				<button class="btn btn-large btn-inverse" id="artist_submit" type="submit"><i class="icon-search icon-white"></i></button>
										</form>
									</div>
								</div>
							</section>
							
							
							<% if (keyword != null) { %>
							<section class="ip-result">
								<% if (keyword.getPositionContent().isEmpty()) { %>
								<div class="row-fluid f-info">
									<div class="span12">
										Sorry, we currently do not collect enough data for <%=keyword.getDomain() %>.
										<br />
										<div class="adv">
											<%=AdsSystem.getAds468x60() %>
										</div>
									</div>
								</div>
								<% } else { %>
								<script type="text/javascript" src="http://www.google.com/jsapi"></script>
								<script type="text/javascript">
								<%=keyword.getChartJs() %>
								</script>
								
								<div class="row-fluid f-info">
									<div class="span12">
										<h4><%=keyword.getDomain() %> Ranking Position Analysis</h4>
										<div class="adv">
											<%=AdsSystem.getAds468x15() %>
											<br />
										</div>
										<ul>
											<li>
												<div id="chart_div_pie"></div>
											</li>
											<li>
												<br />
												<%=keyword.getPositionContent() %>
											</li>
										</ul>
										
										<div class="adv" align="center">
											<%=AdsSystem.getAds468x60() %>
											<br /><br />
										</div>
										
										<h4><%=keyword.getDomain() %> keywords by time</h4>
										<div class="adv">
											<%=AdsSystem.getAds468x15() %>
											<br />
										</div>
										<ul>
											<li>
												<div id="chart_div_line"></div>
											</li>
										</ul>
										
										<div class="adv" align="center">
											<script type="text/javascript"><!--
											google_ad_client = "ca-pub-4975603569119809";
											/* showdomain 468x60 */
											google_ad_slot = "3934035319";
											google_ad_width = 468;
											google_ad_height = 60;
											//-->
											</script>
											<script type="text/javascript"
											src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
											</script>
											<br /><br />
										</div>
										
										<h4>Best of 1 positions for <%=keyword.getDomain() %></h4>
										<ul>
											<li>
												<%=keyword.getBest1position() %>
											</li>
										</ul>
										
										<h4>Best of 2-5 positions for <%=keyword.getDomain() %></h4>
										<ul>
											<li>
												<%=keyword.getBest2positions() %>
											</li>
										</ul>
										
										<h4>Best of 6-10 positions for <%=keyword.getDomain() %></h4>
										<ul>
											<li>
												<%=keyword.getBest10positions() %>
											</li>
										</ul>
									</div>
								</div>
								<% } %>
							</section>
							<% } %>
						</div>
					</div>
				</section>
				
			</div>
			<!-- Main Content -->
			
			<!-- slidebar BEGIN -->
			<jsp:include page="/templates/default/elements/right.jsp" />
			<!-- slidebar END -->
		</div>

<jsp:include page="/templates/default/layouts/footer.jsp" />